package com.example.wirelessapp;

import java.sql.SQLException;
import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class MainActivity extends Activity {

	private Spinner spinnerBlood;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
            	
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
    	initWidget(); //spinner
        addListItem(); //spinner
    	
        myDBClass myDB = new myDBClass(this); // call Class DB
        try {
			myDB.open();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        long profileDB;
        profileDB = myDB.insertProfile(
        		"baboem",
        		"21",
        		"AB");
        myDB.close();
        
    }
    
    private void addListItem() {
		// TODO Auto-generated method stub
		ArrayList<String> bloodList = new ArrayList<String>();
		bloodList.add("A");
		bloodList.add("B");
		bloodList.add("O");
		bloodList.add("AB");
		ArrayAdapter<String> myAdapter= new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, bloodList);
		myAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinnerBlood.setAdapter(myAdapter);
	}

	private void initWidget(){
    	spinnerBlood = (Spinner)findViewById(R.id.spinnerBlood);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
